package com.jaynux.app.provider;

import com.jaynux.app.provider.SamRace.*;

import android.content.*;
import android.database.sqlite.*;
import android.database.sqlite.SQLiteDatabase.*;
import android.util.*;

public class SaveDatabases extends SQLiteOpenHelper {
	
    private static final String TAG = "NotePadProvider";
    private static final String DATABASE_NAME = "note_pad.db";
    private static final int DATABASE_VERSION = 1;
    private static final String NOTES_TABLE_NAME = "notes";
    
	public SaveDatabases(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + NOTES_TABLE_NAME + " ("
                + Notes._ID + " INTEGER PRIMARY KEY,"
                + Notes.TITLE + " TEXT,"
                + Notes.PARTICIPATION_NUMBER + " INTEGER,"
                + Notes.WINING + " INTEGER,"
                + Notes.DISTANCE + " FLOAT,"
                + Notes.RACETIME + " FLOAT"
                + ");");
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS notes");
        onCreate(db);
    }
}
